#include "mywidget.h"

MyWidget::MyWidget(QWidget *parent)
    : QWidget(parent)
{
    this->setWindowTitle("StackWidget_堆栈窗体");
    //this->resize(900,600);

    QListWidget* list = new QListWidget;
    list->insertItem(0,"我的电脑");
    list->insertItem(1,"木马查杀");
    list->insertItem(2,"电脑清理");
    list->insertItem(3,"系统修复");

    //搞四个gif：
    QLabel* label1 = new QLabel;
    QLabel* label2 = new QLabel;
    QLabel* label3 = new QLabel;
    QLabel* label4 = new QLabel;
    QMovie* m1 = new QMovie("1.gif");
    label1->setMovie(m1);
    m1->start();
    QMovie* m2 = new QMovie("2.gif");
    label2->setMovie(m2);
    m2->start();
    QMovie* m3 = new QMovie("3.gif");
    label3->setMovie(m3);
    m3->start();
    QMovie* m4 = new QMovie("4.gif");
    label4->setMovie(m4);
    m4->start();


    QStackedWidget* stack = new QStackedWidget(this);
    stack->addWidget(label1);
    stack->addWidget(label2);
    stack->addWidget(label3);
    stack->addWidget(label4);

    connect(list,SIGNAL(currentRowChanged(int)),stack,SLOT(setCurrentIndex(int)));


    QHBoxLayout* mainLayout = new QHBoxLayout(this);
    mainLayout->addWidget(list);
    mainLayout->addWidget(stack);

    mainLayout->setMargin(15);       //设置边距；
    mainLayout->setSpacing(15);     //设置间隔
    //设置比例：     1:4
    mainLayout->setStretchFactor(list,1);
    mainLayout->setStretchFactor(stack,3);

}

MyWidget::~MyWidget()
{
}

